//	--------------------------------------------------------------------
//	Copyright(C) 2006,2007 Zhao Yukun. All rights reserved.
//	This file is a part of the Xeres system.
//	Xeres 2007
//	Contact : xeres.engine@gmail.com
//	$(reservedInfo)
//	$(reservedDeclaration)
//	--------------------------------------------------------------------
///	@file	<IGeometry.h>
///	@path	~/src/graphics/
///	@date	2007/10/09
///	@desc	Geometry interface.

#pragma once

#include "xeres.h"

#include "graphics/RenderContext.h"
#include "graphics/IDeviceResource.h"
#include "graphics/IShaderAdapter.h"
#include "graphics/IVertexLayout.h"

namespace xeres {

	enum TopologyType
	{
		TOPOLOGY_POINTS ,		// point list
		TOPOLOGY_LINES ,		// line list
		TOPOLOGY_LINESTRIP ,	// line strip
		TOPOLOGY_TRIANGLES ,	// triangle list
		TOPOLOGY_TRISTRIP ,		// triangle strip
		// only DX 9
		TOPOLOGY_TRIFAN ,		// triangle fan
		// only DX 10
		TOPOLOGY_LINES_ADJ ,	// line list with adjacent
		TOPOLOGY_LINESTRIP_ADJ ,// line list with adjacent
		TOPOLOGY_TRIANGLES_ADJ ,// triangle list with adjacent
		TOPOLOGY_TRISTRIP_ADJ ,	// triangle strip with adjacent
		//
		TOPOLOGY_last
	};

	static const wchar_t * TopologyTypeNames [TOPOLOGY_last] = 
	{
		_S("plist") ,
		_S("llist") ,
		_S("lstrip") ,
		_S("tlist") ,
		_S("tstrip") ,
		_S("tfan") ,
		_S("llistA") ,
		_S("llstripA"),
		_S("tlistA") ,
		_S("tstripA") ,
	};

	/*!
		\class	IGeometry
		\brief	Encapsulates a geometry interface.

		\sa IModel
	*/
	class IGeometry : public IDeviceResource
	{
	public:

		/// \name Constructor & Destructor
		//@{

		/// \ctor
		IGeometry( void );

		/// \dtor
		virtual ~IGeometry( void );

		//@}

		DECL_IOBJECT_INTERFACE( IGeometry , IDeviceResource );

	public:

		/// \brief Identify geometry type.
		static TopologyType WhichTopologyType( const WString& type );

		/// \name IGeometry Interface
		//@{

		/*! 
			\brief		Get geometry vertex layout.
		*/
		virtual RefWeak<IVertexLayout> GetLayout( void ) = 0;

		/*! 
			\brief		Prepare draw (apply vertex & index buffer).
		*/
		virtual void EstablishBuffer( RenderContext& rc ) = 0;

		/*!
			\brief		Draw geometry.
		*/
		virtual void Draw( RenderContext& rc ) = 0;

		//@}
	};

} // namespace xeres
